using System.Linq;
using InterfaceWeaver.AopCore;
using Roslyn.Compilers.CSharp;

namespace InterfaceWeaver.CustomTool
{
    public static class InterfaceDeclarationSyntaxExtensions
    {
        /// <summary>
        /// Determines whether the type shoulds skip constructor declaration.
        /// </summary>
        /// <param name="interface"> </param>
        /// <returns></returns>
        public static bool ShouldSkipConstructorDeclaration(this InterfaceDeclarationSyntax @interface)
        {
            return @interface.AttributeLists.SelectMany(attr => attr.Attributes)
                .Any(attr =>
                     attr.IsOfType<WeaverOptionsAttribute>()
                     && attr.HasParameter("SkipConstructorDeclaration")
                     && attr.GetParameterValue<bool>("SkipConstructorDeclaration"));
        }
    }
}